package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import com.ticket.sass.common.entity.tenant.enums.MemberCardOrderRecordFlowType;
import com.ticket.sass.common.entity.tenant.enums.MemberCardOrderRecordType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 交易记录
 * </p>
 *
 * @author ywb
 * @since 2024-03-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("member_card_order_records")
@ApiModel(value="MemberCardOrderRecordsEntity对象", description="交易记录")
public class MemberCardOrderRecordEntity implements Serializable {

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "流水号")
    private String serialNumber;

    @ApiModelProperty(value = "收支类型：1 收入，2 支出")
    private MemberCardOrderRecordFlowType flowType;

    @ApiModelProperty(value = "交易类型：1 充值，2 购票，3 买卖品，4 退款")
    private MemberCardOrderRecordType type;

    @ApiModelProperty(value = "交易描述")
    @TableField("\"desc\"")
    private String desc;

    @ApiModelProperty(value = "交易金额")
    private BigDecimal amount;
    
    @ApiModelProperty(value = "交易后余额")
    private BigDecimal balance;

    @ApiModelProperty(value = "关联订单 id")
    private Long fromOrderId;

    @ApiModelProperty(value = "会员卡 id")
    private Long cardId;

    @ApiModelProperty(value = "用户 id")
    private Long userId;

    @ApiModelProperty(value = "租户 id")
    private Long tenantId;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;
    
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;
    
    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;

    @TableField(exist = false)
    private BigDecimal sumRechargeAmount;

    @TableField(exist = false)
    private BigDecimal sumConsumption;

    @TableField(exist = false)
    private Integer rank;
}
